﻿using MediatR;
using T.Settlement.Domain;
using T.Settlement.Read.API.Application.Command.PaymentCommand;
using T.Settlement.Repository.SettlementInterface;

namespace T.Settlement.Read.API.Application.CommandHandlers.PaymentJandler
{
    public class PaymentBackfillCommandHandler : IRequestHandler<PaymentBackfillCommand, Payment>
    {
        private readonly IPaymentSRepository _paymentSRepository;
        public PaymentBackfillCommandHandler(IPaymentSRepository paymentSRepository)
        {
            _paymentSRepository = paymentSRepository;
        }
        public async Task<Payment> Handle(PaymentBackfillCommand request, CancellationToken cancellationToken)
        {
            return (await _paymentSRepository.GetAllAsync()).Where(x => x.PaymentId == request.PaymentId).FirstOrDefault();
        }
    }
}
